<?php
/**
 * Created by PhpStorm.
 * User: dell
 * Date: 2017/6/14
 * Time: 15:19
 */

namespace Weixin\Service;


use Common\Common\Service;
use Weixin\Component\Weixin\UserComponent;
use Weixin\Exception\WeixinException;
use Weixin\Response\AddUserResponse;

class AddUserService implements Service
{
    public function run()
    {
        $response = new AddUserResponse();
        $component = new UserComponent();
        try {
            $data = $component->addUser();
            if (!$data) {
                $response->setItIsNull();
            } else {
                $response->setUserId($data);
            }
        } catch (WeixinException $e) {
            throw new WeixinException($e->getMessage(), $e->getCode());
        }
        return $response;
    }
}